﻿<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*;" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<%   
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance(); 
String connectionUrl = "jdbc:sqlserver://localhost:1433;databaseName=database1;user=sa;password=sa;";   
Connection conn = DriverManager.getConnection(connectionUrl);   
  
 Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);    
  String sql="select * from dataTableName";    
  ResultSet rs=stmt.executeQuery(sql);    
 while(rs.next()) {%>    
  您的第一个字段内容为：<%=rs.getString(1)%> <br>   
  您的第二个字段内容为：<%=rs.getString(2)%> <br>   
  您的第三个字段内容为：<%=rs.getString(3)%> <br>   
  <%}%>    
  <%out.print("数据库操作成功，恭喜你");%>    
 <%rs.close();    
  stmt.close();    
  conn.close();      
  %>   

</body>
</html>